/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
 * Copyright(c) 2023 John Sanpe <sanpeqf@gmail.com>
 */

#include <bfdev/bcd.h>
#include <export.h>

export const bfdev_u8
bfdev_bcd2bin_table[256] = {
    [0 ... 255] = BFDEV_UINT8_MAX,
    [0x00] =  0, [0x01] =  1, [0x02] =  2, [0x03] =  3, [0x04] =  4,
    [0x05] =  5, [0x06] =  6, [0x07] =  7, [0x08] =  8, [0x09] =  9,
    [0x10] = 10, [0x11] = 11, [0x12] = 12, [0x13] = 13, [0x14] = 14,
    [0x15] = 15, [0x16] = 16, [0x17] = 17, [0x18] = 18, [0x19] = 19,
    [0x20] = 20, [0x21] = 21, [0x22] = 22, [0x23] = 23, [0x24] = 24,
    [0x25] = 25, [0x26] = 26, [0x27] = 27, [0x28] = 28, [0x29] = 29,
    [0x30] = 30, [0x31] = 31, [0x32] = 32, [0x33] = 33, [0x34] = 34,
    [0x35] = 35, [0x36] = 36, [0x37] = 37, [0x38] = 38, [0x39] = 39,
    [0x40] = 40, [0x41] = 41, [0x42] = 42, [0x43] = 43, [0x44] = 44,
    [0x45] = 45, [0x46] = 46, [0x47] = 47, [0x48] = 48, [0x49] = 49,
    [0x50] = 50, [0x51] = 51, [0x52] = 52, [0x53] = 53, [0x54] = 54,
    [0x55] = 55, [0x56] = 56, [0x57] = 57, [0x58] = 58, [0x59] = 59,
    [0x60] = 60, [0x61] = 61, [0x62] = 62, [0x63] = 63, [0x64] = 64,
    [0x65] = 65, [0x66] = 66, [0x67] = 67, [0x68] = 68, [0x69] = 69,
    [0x70] = 70, [0x71] = 71, [0x72] = 72, [0x73] = 73, [0x74] = 74,
    [0x75] = 75, [0x76] = 76, [0x77] = 77, [0x78] = 78, [0x79] = 79,
    [0x80] = 80, [0x81] = 81, [0x82] = 82, [0x83] = 83, [0x84] = 84,
    [0x85] = 85, [0x86] = 86, [0x87] = 87, [0x88] = 88, [0x89] = 89,
    [0x90] = 90, [0x91] = 91, [0x92] = 92, [0x93] = 93, [0x94] = 94,
    [0x95] = 95, [0x96] = 96, [0x97] = 97, [0x98] = 98, [0x99] = 99,
};

export const bfdev_u8
bfdev_bin2bcd_table[256] = {
    [0 ... 255] = BFDEV_UINT8_MAX,
    [ 0] = 0x00, [ 1] = 0x01, [ 2] = 0x02, [ 3] = 0x03, [ 4] = 0x04,
    [ 5] = 0x05, [ 6] = 0x06, [ 7] = 0x07, [ 8] = 0x08, [ 9] = 0x09,
    [10] = 0x10, [11] = 0x11, [12] = 0x12, [13] = 0x13, [14] = 0x14,
    [15] = 0x15, [16] = 0x16, [17] = 0x17, [18] = 0x18, [19] = 0x19,
    [20] = 0x20, [21] = 0x21, [22] = 0x22, [23] = 0x23, [24] = 0x24,
    [25] = 0x25, [26] = 0x26, [27] = 0x27, [28] = 0x28, [29] = 0x29,
    [30] = 0x30, [31] = 0x31, [32] = 0x32, [33] = 0x33, [34] = 0x34,
    [35] = 0x35, [36] = 0x36, [37] = 0x37, [38] = 0x38, [39] = 0x39,
    [40] = 0x40, [41] = 0x41, [42] = 0x42, [43] = 0x43, [44] = 0x44,
    [45] = 0x45, [46] = 0x46, [47] = 0x47, [48] = 0x48, [49] = 0x49,
    [50] = 0x50, [51] = 0x51, [52] = 0x52, [53] = 0x53, [54] = 0x54,
    [55] = 0x55, [56] = 0x56, [57] = 0x57, [58] = 0x58, [59] = 0x59,
    [60] = 0x60, [61] = 0x61, [62] = 0x62, [63] = 0x63, [64] = 0x64,
    [65] = 0x65, [66] = 0x66, [67] = 0x67, [68] = 0x68, [69] = 0x69,
    [70] = 0x70, [71] = 0x71, [72] = 0x72, [73] = 0x73, [74] = 0x74,
    [75] = 0x75, [76] = 0x76, [77] = 0x77, [78] = 0x78, [79] = 0x79,
    [80] = 0x80, [81] = 0x81, [82] = 0x82, [83] = 0x83, [84] = 0x84,
    [85] = 0x85, [86] = 0x86, [87] = 0x87, [88] = 0x88, [89] = 0x89,
    [90] = 0x90, [91] = 0x91, [92] = 0x92, [93] = 0x93, [94] = 0x94,
    [95] = 0x95, [96] = 0x96, [97] = 0x97, [98] = 0x98, [99] = 0x99,
};
